/*
 * Copyright (C) 2010-2011 sunjumper@163.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *  http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package mf.demo;

import java.io.File;
import java.net.URISyntaxException;
import mf.mfrpc.client.RPCHttpClient;
import mf.mfrpc.client.WSHttpClient;
import mf.mfrpc.parser.HessianParser;
import mf.mfrpc.parser.KryoParser;
import mf.mfrpc.serialize.Parser;

/**
 * BaseUtil
 */
public class BaseUtil {

    private static File file1 = null;

    private static File file2 = null;

    static {
        try {
            file1 = new File(BaseUtil.class.getResource("/test1.txt").toURI());
            file2 = new File(BaseUtil.class.getResource("/test2.txt").toURI());

            assert file1.exists();
            assert file2.exists();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }

    public static File getTestFile1() {
        return file1;
    }

    public static File getTestFile2() {
        return file2;
    }
    //default Parser
    static Parser parser = new KryoParser();
//    static Parser parser = new HessianParser();

    public static <T> RPCHttpClient<T> getRPCHttpClient(String url) {
        return new RPCHttpClient(url, parser);
    }

    public static <T> RPCHttpClient<T> getRPCHttpClient(String url, Parser parser) {
        return new RPCHttpClient(url, parser);
    }

    public static WSHttpClient getWSHttpClient(String url) {
        return new WSHttpClient(url, parser);
    }

    public static WSHttpClient getWSHttpClient(String url, Parser parser) {
        return new WSHttpClient(url, parser);
    }
}
